#include"UdpClient.hpp"
#include<iostream>
#include<signal.h>
#include <memory>
#include <unistd.h>

std::unique_ptr<Client> client_ptr;

void handle(int signal)
{
    std::cout<<"用户退出"<<std::endl;
    exit(0);
}

int main(int argc,char* argv[])
{
    ::signal(SIGINT,handle);

    // ./udp_server 127.0.0.1 8080
    if(argc!=3)
    {
        std::cout<<"Usage ./client_server 47.98.139.142 8080"<<std::endl;
        return 1;
    }
    std::string ip=argv[1];
    uint16_t port= ::atoi(argv[2]);
    ///Client client(ip,port);

    client_ptr = std::unique_ptr<Client>(new Client(ip, port));
    
    client_ptr->InitClient();
    client_ptr->Start();
    // client.InitClient();

    // client.Start();
    

    return 0;
}